<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="lib/vue.js"></script>
    <title>选项卡练习</title>
    <style>
      body{
          font-family: Arial, Helvetica, sans-serif;
      }
      .tab{
          width: 600px;
          margin: 0 auto;
          border: 1px solid black;
      }
      .header{
          font-size: 0;
          width: 600px;
          border-bottom: 1px solid#666;
      }
      .header a {
          display: inline-block;
          height: 40px;
          line-height: 40px;
          font-size: 16px;
          width: 25%;
          text-align: center;
          color: #333;
          text-decoration: none;
      }
      .selected{
          background-color: rgb(195, 0, 255);
          color: #fff !important;
      }
      .show>div{
          border: 1px solid #ccc;
          height: 400px;
          padding-top: 20px;
      }
    </style>
</head>
<body>
    <div id="app">
        <div class="tab">
            <div class="header">
                <a :class="{selected:currentpage==0}" href="#" @click.prevent="changepage(0)">HTML</a>
                <a :class="{selected:currentpage==1}" href="#" @click.prevent="changepage(1)">CSS</a>
                <a :class="{selected:currentpage==2}" href="#" @click.prevent="changepage(2)">JavaScript</a>
                <a :class="{selected:currentpage==3}" href="#" @click.prevent="changepage(3)">Vue</a>
            </div>
            <div class="show">
                <div v-show="currentpage==0">HTML</div>
                <div v-show="currentpage==1">CSS</div>
                <div v-show="currentpage==2">JavaScript</div>
                <div v-show="currentpage==3">Vue</div>
            </div>
        </div>
    </div>
</body>
<script>
     var vm = new Vue({
         el:'#app',
         data:{
              currentpage:0
         },
         methods:{
             changepage(page){
                 this.currentpage=page
             }
         }
     })
</script>
</html>